var tblSchedule;
$(function () {
    tblSchedule = $('#tbl-schedule').DataTable(buildlScheduleOptions());
    trCssEvent(tblSchedule);
    $("#btn-search-schedule").click(scheduleSearch);
});

function buildlScheduleOptions() {
    var options = {
        "deferRender": true,
        "searching": false,
        "ordering": true,
        "processing": true,
        "scrollX": true,
        "language": {
            "url": plugPath + 'DataTables/chinese.json'
        },
        "serverSide": true,
        "ajax": {
            "url": basePath + "teacher/getClassScheduleData",
            "type": 'POST',
            data: function (params) {
                params['teacherId'] = $("#teacherId").val();
                params['childId'] = $("#childId").val();
                params['courseId'] = $("#courseId").val();
            }
        },

        "columns": [{
            "data": "courseName"
        }, {
            "data": "date"
        }, {
            "data": "weekDay"
        }, {
            "data": "time"
        }, {
            "data": "signStatus"
        },
        //     {
        //     "data": "score"
        // }, 
            {
            "data": "id"
        }],

        columnDefs: [{
            "targets": 5,
            "data": "id",
            "render": function (data, type, row, meta, full) {
               var childId = $("#childId").val();
                // return "<a href='http://sp.jinseyulin.cn/print?id="+data+"&child_id="+childId+"&dpi=180' class='btn btn-primary' target='_blank'> 查看题目  </a>"
                return "<a href='goScheduleProPage?scheduleId="+data+"&childId="+childId+"' target='_blank' >【配置该课程项目】</a>";

            }
        },{"orderable": false, "targets": [0,2,3,4]}
        ],

        "dom": "<'row'<'col-xs-12't>><'row'<'col-xs-2 lstyle'l><'col-xs-3'i><'col-xs-6  fright'p>>"

    };
    return options;
}


//查询搜索中心
function scheduleSearch() {
    $("#btn-search-schedule").attr("disabled", "disabled");
    tblSchedule.ajax.reload(function () {
        $("#btn-search-schedule").removeAttr("disabled");
    });
}